﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BusinessObjects.BO_GetObjects;
using BussinessObjects;
using BusinessObjects;
using LibraryO2S;

public partial class controls_admin_GroupAdmin : Pages_Base
{
    protected void Page_Load(object sender, EventArgs e)
    {
        base.removeHGC(divMessage);
        if (!IsPostBack)
        {
            loadGroups();
        }
    }
    protected void loadGroups()
    {
        try
        {
            base.OpenConnection();
            int g_id = 0;
            if (Request["g_id"] != null)
                g_id = Convert.ToInt32(Request["g_id"]);
            DataTable objDT = BO_Sec_Group_Admin.SelectParent(1, g_id);
            bindRepeater(rptData, objDT, divMessage);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            base.CloseConnection();
        }
    }
    protected void btnNew_Click(object sender, EventArgs e)
    {
        Response.Redirect("default.aspx?module=groupadminadd");
    }
    protected void rptData_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            Button btnID = (Button)e.Item.FindControl("btnID");
            if (e.CommandName.Equals("del"))
            {
                BO_Sec_Group_Admin.Delete(Convert.ToInt32(btnID.CommandArgument));
                divMessage.InnerHtml = O2S_Message.Success("Thông Báo", "Xóa thành công .");
            }
            loadGroups();
        }
        catch (Exception ex)
        {
            divMessage.InnerHtml = O2S_Message.Error("Lỗi", "Phát hiện lỗi: <br />" + ex.Message);
        }
    }
}
